package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface JurisdictionDao {
    Page<Permission> findByPage(@Param("queryString") String queryString);

    void add(Permission permission);

    @Select("SELECT count(id) from t_permission where name = #{name}")
    Long nameQuery(String name);

    @Select("SELECT count(id) from t_permission where keyword = #{keyword}")
    Long keywordQuery(String keyword);

    @Delete("DELETE from t_permission where id =#{id}")
    void delById(Integer id);

    @Select("SELECT * FROM t_permission where id = #{id}")
    Permission findById(Integer id);

    @Select("SELECT * FROM t_role ")
    List<Role> findAll();

    void addRole(@Param("permission") Integer id, @Param("id") Integer integer);

    @Select("DELETE from t_role_permission where permission_id = #{id}")
    void deleteRelationship(Integer id);

    @Select("SELECT * from t_role ")
    List<Role> findAllRole();

    @Select("SELECT role_id from t_role_permission where permission_id = #{id}")
    Integer[] findByIdRole(Integer id);

    void updatePermission(Permission permission);

    @Delete("DELETE from t_role_permission where permission_id =#{id}")
    void delRelation(Integer id);
}
